home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 1.iso / dist / fw_qt.idb / usr / freeware / include / qlineedit.h.z / qlineedit.h
C/C++ Source or Header  |  2001-04-12  |  6KB  |  219 lines

  1. /**********************************************************************
  2. ** $Id: qt/src/widgets/qlineedit.h   2.3.0   edited 2001-02-06 $
  3. **
  4. ** Definition of QLineEdit widget class
  5. **
  6. ** Created : 941011
  7. **
  8. ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved.
  9. **
  10. ** This file is part of the widgets module of the Qt GUI Toolkit.
  11. **
  12. ** This file may be distributed under the terms of the Q Public License
  13. ** as defined by Trolltech AS of Norway and appearing in the file
  14. ** LICENSE.QPL included in the packaging of this file.
  15. **
  16. ** This file may be distributed and/or modified under the terms of the
  17. ** GNU General Public License version 2 as published by the Free Software
  18. ** Foundation and appearing in the file LICENSE.GPL included in the
  19. ** packaging of this file.
  20. **
  21. ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
  22. ** licenses may use this file in accordance with the Qt Commercial License
  23. ** Agreement provided with the Software.
  24. **
  25. ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
  26. ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  27. **
  28. ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
  29. **   information about Qt Commercial License Agreements.
  30. ** See http://www.trolltech.com/qpl/ for QPL licensing information.
  31. ** See http://www.trolltech.com/gpl/ for GPL licensing information.
  32. **
  33. ** Contact info@trolltech.com if any conditions of this licensing are
  34. ** not clear to you.
  35. **
  36. **********************************************************************/
  37.  
  38. #ifndef QLINEEDIT_H
  39. #define QLINEEDIT_H
  40.  
  41. struct QLineEditPrivate;
  42.  
  43. class QComboBox;
  44. class QValidator;
  45.  
  46.  
  47. #ifndef QT_H
  48. #include "qwidget.h"
  49. #include "qstring.h"
  50. #endif // QT_H
  51.  
  52. #ifndef QT_NO_LINEEDIT
  53.  
  54. class Q_EXPORT QLineEdit : public QWidget
  55. {
  56.     Q_OBJECT
  57.     Q_ENUMS( EchoMode )
  58.     Q_PROPERTY( QString text READ text WRITE setText )
  59.     Q_PROPERTY( int maxLength READ maxLength WRITE setMaxLength )
  60.     Q_PROPERTY( bool frame READ frame WRITE setFrame )
  61.     Q_PROPERTY( EchoMode echoMode READ echoMode WRITE setEchoMode )
  62.     Q_PROPERTY( QString displayText READ displayText )
  63.     Q_PROPERTY( int cursorPosition READ cursorPosition WRITE setCursorPosition )
  64.     Q_PROPERTY( Alignment alignment READ alignment WRITE setAlignment )
  65.     Q_PROPERTY( bool edited READ edited WRITE setEdited )
  66.     Q_PROPERTY( bool hasMarkedText READ hasMarkedText )
  67.     Q_PROPERTY( QString markedText READ markedText )
  68.     
  69. public:
  70.     QLineEdit( QWidget *parent, const char *name=0 );
  71.     QLineEdit( const QString &, QWidget *parent, const char *name=0 );
  72.    ~QLineEdit();
  73.  
  74.     QString text() const;
  75.  
  76.     QString displayText() const;
  77.  
  78.     int        maxLength()    const;
  79.     virtual void setMaxLength( int );
  80.  
  81.     virtual void setFrame( bool );
  82.     bool    frame() const;
  83.  
  84.     enum    EchoMode { Normal, NoEcho, Password };
  85.     virtual void setEchoMode( EchoMode );
  86.     EchoMode     echoMode() const;
  87. #if QT_VERSION >= 300
  88. #error "Make setReadOnly virtual"
  89. #endif
  90.     void setReadOnly( bool );
  91.     bool isReadOnly() const;
  92.  
  93.     virtual void setValidator( const QValidator * );
  94.     const QValidator * validator() const;
  95.  
  96.     QSize    sizeHint() const;
  97.     QSize    minimumSizeHint() const;
  98.     QSizePolicy sizePolicy() const;
  99.  
  100.     virtual void setEnabled( bool );
  101.     virtual void setFont( const QFont & );
  102.     virtual void setPalette( const QPalette & );
  103.     virtual void setSelection( int, int );
  104.  
  105.     virtual void setCursorPosition( int );
  106.     int        cursorPosition() const;
  107.  
  108.     bool    validateAndSet( const QString &, int, int, int );
  109.  
  110. #ifndef QT_NO_CLIPBOARD
  111.     void    cut();
  112.     void    copy() const;
  113.     void    paste();
  114. #endif
  115.  
  116.     void setAlignment( int flag );
  117.     int alignment() const;
  118.  
  119.     void    cursorLeft( bool mark, int steps = 1 );
  120.     void    cursorRight( bool mark, int steps = 1 );
  121.     void    cursorWordForward( bool mark );
  122.     void    cursorWordBackward( bool mark );
  123.     void    backspace();
  124.     void    del();
  125.     void    home( bool mark );
  126.     void    end( bool mark );
  127.  
  128.     void    setEdited( bool );
  129.     bool    edited() const;
  130.  
  131.     bool    hasMarkedText() const;
  132.     QString    markedText() const;
  133.  
  134. public slots:
  135.     virtual void setText( const QString &);
  136.  
  137.     void    selectAll();
  138.     void    deselect();
  139.  
  140.     void    clearValidator();
  141.  
  142.     void    insert( const QString &);
  143.  
  144.     void    clear();
  145.  
  146. signals:
  147.     void    textChanged( const QString &);
  148.     void    returnPressed();
  149.  
  150. protected:
  151.     bool    event( QEvent * );
  152.     void    mousePressEvent( QMouseEvent * );
  153.     void    mouseMoveEvent( QMouseEvent * );
  154.     void    mouseReleaseEvent( QMouseEvent * );
  155.     void    mouseDoubleClickEvent( QMouseEvent * );
  156.     void    keyPressEvent( QKeyEvent * );
  157.     void    focusInEvent( QFocusEvent * );
  158.     void    focusOutEvent( QFocusEvent * );
  159.     void    paintEvent( QPaintEvent * );
  160.     void    resizeEvent( QResizeEvent * );
  161.     void    leaveEvent( QEvent * );
  162. #ifndef QT_NO_DRAGANDDROP
  163.     void    dragEnterEvent( QDragEnterEvent * );
  164.     void    dropEvent( QDropEvent * );
  165. #endif
  166.  
  167.     void    repaintArea( int, int );
  168.  
  169. private slots:
  170.     void    clipboardChanged();
  171.     void    blinkSlot();
  172.     void    dragScrollSlot();
  173. #ifndef QT_NO_DRAGANDDROP
  174.     void     doDrag();
  175. #endif
  176.  
  177. private:
  178.     // kept
  179.     void    newMark( int pos, bool copy=TRUE );
  180.     void    markWord( int pos );
  181.     int        lastCharVisible() const;
  182.     int        minMark() const;
  183.     int        maxMark() const;
  184.     int        frameW() const;
  185.  
  186.     void    init();
  187.  
  188.     QString    tbuf;
  189.     QLineEditPrivate * d;
  190.     int        cursorPos;
  191.     int        offset;
  192.     int        maxLen;
  193.     int        markAnchor;
  194.     int        markDrag;
  195.     bool    cursorOn;
  196.     bool    dragScrolling;
  197.     bool    scrollingLeft;
  198.     int        alignmentFlag;
  199.     bool    ed;
  200.  
  201.     void updateOffset();
  202.     int xPosToCursorPos( int ) const;
  203.     void blinkOn();
  204.     void makePixmap() const;
  205.     void undoInternal();
  206.     void redoInternal();
  207.  
  208. private:    // Disabled copy constructor and operator=
  209. #if defined(Q_DISABLE_COPY)
  210.     QLineEdit( const QLineEdit & );
  211.     QLineEdit &operator=( const QLineEdit & );
  212. #endif
  213. };
  214.  
  215.  
  216. #endif // QT_NO_LINEEDIT
  217.  
  218. #endif // QLINEEDIT_H
  219.